home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F29030_easyDiffList.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-11-06  |  4.2 KB  |  111 lines

  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2. xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  3. xmlns:myHalve="myHalve" 
  4. xmlns:myTenXController="myTenXController" 
  5. xmlns:myEasyDiffMap="myEasyDiffMap"
  6. xmlns:myWithinController="myWithinController"
  7. exclude-result-prefixes="xsl msxsl myHalve myTenXController
  8.  myEasyDiffMap myWithinController"
  9. >
  10.   <xsl:import href="buildListWhileMap.xsl"/>
  11.   <myHalve:myHalve/>
  12.   <myWithinController:myWithinController/>
  13.   <myTenXController:myTenXController/>
  14.   <myEasyDiffMap:myEasyDiffMap/>
  15.   
  16.   <xsl:template name="easyDiffList">
  17.     <xsl:param name="pFun" select="/.."/>
  18.     <xsl:param name="pX"/>
  19.     <xsl:param name="pH0" select="0.1"/>
  20.     <xsl:param name="pEps" select="0.01"/>
  21.     
  22.     <xsl:variable name="vMyHalveGenerator" select="document('')/*/myHalve:*[1]"/>
  23.     <xsl:variable name="vmyWithinController" select="document('')/*/myWithinController:*[1]"/>
  24.     <xsl:variable name="vmyTenXController" select="document('')/*/myTenXController:*[1]"/>
  25.     <xsl:variable name="vmyEasyDiffMap" select="document('')/*/myEasyDiffMap:*[1]"/>
  26.   
  27.     <xsl:variable name="fx">
  28.       <xsl:apply-templates select="$pFun">
  29.         <xsl:with-param name="pParam" select="$pX"/>
  30.       </xsl:apply-templates>
  31.     </xsl:variable>
  32.     
  33.     <xsl:variable name="vrtfMapParams">
  34.       <xsl:copy-of select="$pFun"/>
  35.       <param><xsl:value-of select="$pX"/></param>
  36.       <param><xsl:value-of select="$fx"/></param>
  37.     </xsl:variable>
  38.     
  39.     <xsl:variable name="vMapParams" select="msxsl:node-set($vrtfMapParams)/*"/>
  40.     
  41.     <xsl:call-template name="buildListWhileMap">
  42.         <xsl:with-param name="pGenerator" select="$vMyHalveGenerator"/>
  43.         <xsl:with-param name="pParam0" select="$pH0"/>
  44.         <xsl:with-param name="pController" select="$vmyWithinController"/>
  45.         <xsl:with-param name="pContollerParam" select="$pEps"/>
  46.         <xsl:with-param name="pMap" select="$vmyEasyDiffMap"/>
  47.         <xsl:with-param name="pMapParams" select="$vMapParams"/>
  48.     </xsl:call-template>
  49.   </xsl:template>
  50.   
  51.   <xsl:template name="myHalveGenerator" match="*[namespace-uri()='myHalve']">
  52.      <xsl:param name="pParams" select="/.."/>
  53.      <xsl:param name="pList" select="/.."/>
  54.      
  55.      <xsl:choose>
  56.        <xsl:when test="not($pList)"><xsl:value-of select="$pParams"/></xsl:when>
  57.        <xsl:otherwise><xsl:value-of select="$pList[last()] div 2"/></xsl:otherwise>
  58.      </xsl:choose>
  59.   </xsl:template>
  60.   
  61.   <xsl:template name="myWithinController" match="*[namespace-uri()='myWithinController']">
  62.      <xsl:param name="pParams" select="/.."/>
  63.      <xsl:param name="pList" select="/.."/>
  64.      
  65.      <xsl:variable name="vLastDiff" select="$pList[last()] - $pList[last() - 1]"/>
  66.      
  67.      
  68.      <xsl:choose>
  69.        <xsl:when test="not($vLastDiff < $pParams 
  70.                       and $vLastDiff > (0 - $pParams))
  71.                       and count($pList) <= 40
  72.                       ">1</xsl:when>
  73.      </xsl:choose>
  74.   </xsl:template>
  75.  
  76.   <xsl:template name="myEasyDiffMap" match="*[namespace-uri()='myEasyDiffMap']">
  77.      <xsl:param name="pParams" select="/.."/>
  78.      <xsl:param name="pDynParams" select="/.."/>
  79.      <xsl:param name="pList" select="/.."/>
  80.      
  81.      <xsl:variable name="x" select="$pParams[2]"/>
  82.      <xsl:variable name="h" select="$pDynParams[1]"/>
  83.      
  84.      
  85.      <xsl:choose>
  86.          <xsl:when test="not($h = 0)">
  87.              <xsl:variable name="fx_plus_h">
  88.                  <xsl:apply-templates select="$pParams[1]">
  89.                    <xsl:with-param name="pParam" select="$x + $h"/>
  90.                  </xsl:apply-templates>
  91.              </xsl:variable>
  92.              
  93.              <xsl:variable name="fx">
  94.                  <xsl:choose>
  95.                      <xsl:when test="count($pParams) >= 3">
  96.                        <xsl:value-of select="$pParams[3]"/>
  97.                      </xsl:when>
  98.                      <xsl:otherwise>
  99.                          <xsl:apply-templates select="$pParams[1]">
  100.                            <xsl:with-param name="pParam" select="$x"/>
  101.                          </xsl:apply-templates>
  102.                      </xsl:otherwise>
  103.                  </xsl:choose>
  104.              </xsl:variable>
  105.              
  106.              <xsl:value-of select="($fx_plus_h - $fx) div $h"/>
  107.          </xsl:when>
  108.          <xsl:otherwise><xsl:value-of select="$pList[last()]"/></xsl:otherwise>
  109.      </xsl:choose>
  110.   </xsl:template>
  111. </xsl:stylesheet>